<?php

/*

Desktopd Colors
Copyright (C) 2015  Desktopd Developer(s)

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

https://www.gnu.org/licenses/agpl.html

*/


namespace Desktopd\Colors;


class XYZ {
    protected $X = 1;
    protected $Y = 1;
    protected $Z = 1;
    
    public function __construct($X, $Y, $Z) {
        list(
            $this->X,
            $this->Y,
            $this->Z
        ) = array_map(function($c) {
            if (!is_numeric($c)) {
                throw new \InvalidArgumentException(print_r($c, true) . ' is not numeric');
            }
            
            return (float) $c;
        }, array($X, $Y, $Z));
        
    }
    
    public function __toString() {
        return "XYZ: ({$this->X}, {$this->Y}, {$this->Z})";
    }
    
    public function getX() {
        return $this->X;
    }
    
    public function getY() {
        return $this->Y;
    }
    
    public function getZ() {
        return $this->Z;
    }
}


// vim: ts=4 et ai

